#define  _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<stdlib.h>
#include<time.h>

typedef int ElemType;
typedef struct ss_table {
	ElemType* data;
	int TableLen;
}SS_table;


void StInite(SS_table &ST,int tabelen)
{

	ST.TableLen = tabelen + 1;
	ST.data = (ElemType*)malloc(sizeof(ST.TableLen));
	srand((unsigned)time(NULL));
	for (int i = 1; i < ST.TableLen; i++)
	{
		ST.data[i] = rand() % 100;
	}
}

void PrintSt(SS_table ST)
{
	for (int i = 1; i < ST.TableLen ; i++)
	{
		printf("%3d", ST.data[i]);
	}
	printf("\n");
}


int StSerachkey(SS_table ST, ElemType key)
{
	ST.data[0] = key;
	int i;
	for (i = ST.TableLen - 1; ST.data[i] != key; i--);

	return i;
}
int main()
{
	SS_table ST;
	StInite(ST,10);
	PrintSt(ST);

	ElemType key;
	printf("please input serach key:\n");
	scanf("%d", &key);
	int pos=0;
	pos=StSerachkey(ST, key);
	if (pos)
	{
		printf("find out,the pos:%d\n", pos);
	}
	else
	{
		printf("find failed\n");
	}
	return 0;
}